<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <!--edge浏览器H5兼容设置-->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!--360浏览器H5兼容设置-->
    <meta name="renderer" content="webkit"/>
    <title>香蕉手机商城</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!--导入核心文件-->
    <script th:src="@{/bootstrap3/js/holder.js}"></script>
    <link th:href="@{/bootstrap3/css/bootstrap.css}" rel="stylesheet" type="text/css">
    <script th:src="@{/bootstrap3/jquery-1.8.3.min.js}"></script>
    <script th:src="@{/bootstrap3/js/bootstrap.js}"></script>
    <script th:src="@{/js/menu.js}" type="text/javascript" charset="utf-8"></script>
    <!-- 字体图标 -->
    <link rel="stylesheet" th:href="@{/bootstrap3/font-awesome-4.7.0/css/font-awesome.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/css/layout.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/css/webindex.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/css/footer.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/css/top.css}"/>
</head>

<body>
<!--头部-->
<header class="header">
    <!--电脑商城logo-->
    <div class="row">
        <div class="col-md-3">
            <a th:href="@{/goIndex}">
                <img th:src="@{/images/index/BananaPhone.png}"/>
            </a>
        </div>
        <!--快捷选项-->
        <div class="col-md-9 top-item">
            <ul class="list-inline pull-right">
                <li><a th:href="@{/goOrders}"><span class="fa fa-file-text"></span>&nbsp;订单</a></li>
                <li class="li-split">|</li>
                <li><a th:href="@{/goCart}"><span class="fa fa-cart-plus"></span>&nbsp;购物车</a></li>
                <li class="li-split">|</li>
                <li>
                    <!--下列列表按钮 ：管理-->
                    <div class="btn-group">
                        <button type="button" class="btn btn-link dropdown-toggle" data-toggle="dropdown">
                            <span id="top-dropdown-btn"><span class="fa fa-gears"></span>&nbsp;管理 <span
                                    class="caret"></span></span>
                        </button>
                        <ul class="dropdown-menu top-dropdown-ul" role="menu">
                            <li><a th:href="@{/goPassword}">修改密码</a></li>
                            <li><a th:href="@{/goUserdata}">个人资料</a></li>
                            <li><a th:href="@{/goShowAddress}">收货管理 </a></li>
                        </ul>
                    </div>
                </li>
                <li class="li-split">|</li>
                <li><a th:href="@{/goLogin}"><span class="fa fa-user"></span>&nbsp;登录</a></li>
            </ul>
        </div>
    </div>
</header>
<!--导航 -->
<!--分割导航和顶部-->
<div class="row top-nav">
    <div class="col-md-6">
        <ul class="nav nav-pills">
            <li class="active"><a th:href="@{/goIndex}"><span class="fa fa-home"></span></a></li>
        </ul>
    </div>
<!--    <div class="col-md-6">-->
<!--        <form th:action="@{/goSearch}" class="form-inline pull-right" role="form">-->
<!--            <div class="form-group">-->
<!--                <input type="text" class="form-control" id="search" name="search" placeholder="请输入商品名称进行搜索">-->
<!--            </div>-->
<!--            <button type="submit" class="btn btn-default btn-sm"><span class="fa fa-search"></span></button>-->
<!--        </form>-->
<!--    </div>-->
</div>
<!--头部结束-->
<!--导航结束-->
<div class="container">
    <div class="row">
        <div class="col-md-10">
            <div id="myCarousel" class="carousel slide">
                <!-- 轮播（Carousel）指标 -->
                <ol class="carousel-indicators">
                    <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
                    <li data-target="#myCarousel" data-slide-to="1"></li>
                    <li data-target="#myCarousel" data-slide-to="2"></li>
                    <li data-target="#myCarousel" data-slide-to="3"></li>
                    <li data-target="#myCarousel" data-slide-to="4"></li>
                </ol>
                <!-- 轮播（Carousel）项目 -->
                <div class="carousel-inner" align="center">
                    <div class="item active">
                        <img src="../images/index/index1.jpg">
                    </div>
                    <div class="item">
                        <img src="../images/index/index2.jpg">
                    </div>
                    <div class="item">
                        <img src="../images/index/index3.jpg">
                    </div>
                    <div class="item">
                        <img src="../images/index/index4.jpg">
                    </div>
                    <div class="item">
                        <img src="../images/index/index5.jpg">
                    </div>
                </div>
                <!-- 轮播（Carousel）导航 -->
                <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
                    <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
                    <span class="sr-only">Previous</span>
                </a>
                <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
                    <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
                    <span class="sr-only">Next</span>
                </a>
            </div>
        </div>
    </div>

    <!--推荐栏目-->
    <div class="row">
        <div class="col-md-6">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <p class="panel-title">热销排行</p>
                </div>
                <div id="hot-list" class="panel-body panel-item">

                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(document).ready(function () {
        showHotList();
    });

    function showHotList() {
        $("#hot-list").empty();
        $.ajax({
            url: "/product/showHotProduct",
            type: "GET",
            dataType: "JSON",
            success: function (data) {
                let list = data;
                console.log("count=" + list.length);
                for (let i = 0; i < list.length; i++) {
                    console.log(list[i].title);
                    let html = '<div class="col-md-12">'
                        + '<div class="col-md-7 text-row-2"><a href="/goProductOne?id=#{id}">#{title}</a></div>'
                        + '<div class="col-md-2">¥#{price}</div>'
                        + '<div class="col-md-3"><img src="..#{image}phone.jpg" class="img-responsive" /></div>'
                        + '</div>';

                    html = html.replace(/#{id}/g, list[i].id);
                    html = html.replace(/#{title}/g, list[i].title);
                    html = html.replace(/#{price}/g, list[i].price);
                    html = html.replace(/#{image}/g, list[i].image);

                    $("#hot-list").append(html);
                }
            }
        });
    }
</script>

</body>

</html>